package com.kaifamiao.strings;

public class StringCompareTest {

	public static void main(String[] args) {
		
		String a = "开发喵" ;
		String b = "云创动力" ;
		
		System.out.println( a.equals( b ) );
		System.out.println( a.contentEquals( b ) );
		System.out.println( a.compareTo( b ) );
		
		String c = "kaifamiao" ;
		String d = "KaiFaMiao" ;
		System.out.println( c.equals( d ) );
		System.out.println( c.equalsIgnoreCase( d ) );
		
		String e = new String( c ) ;
		System.out.println( e == c ); // false 
		System.out.println( e.equals(c) ); // true
		
		System.out.println( e.hashCode() == c.hashCode() ); // 不靠谱
		System.out.println( "儿女".hashCode() == "农丰".hashCode() ); // 反例
		
		System.out.println( e.compareTo( c ) ); // 等于零表示两者相等
		System.out.println( e.compareToIgnoreCase( d ) ); // 忽略大小写的比较
		
		System.out.println( e.contentEquals( c ) );

	}

}
